#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/3/23 11:56
# @Author : 闫峰
# @File    : delete_word.py
import re

smsm = ["{", "}", "-", "—", ",", ",", ":", "：", ".", "。", ";", "；", "!", "！", "?", "?", "<", ">", "￥", "$", "~", "^",
        "*", "%", "\\", "‘", "\"", "/", "=", "#", "|", "+", "[", "【", "]", "】", "&", " "]


def delete_word(string_str, sen_word):
    new_string_str = "?" + string_str + "?"
    chuli_jieshu = ""
    while re.search(sen_word, new_string_str):
        res = re.search(sen_word, new_string_str)
        if new_string_str[res.start() - 1] in smsm and new_string_str[res.end()] in smsm:
            # 命中了
            yuanshu = new_string_str
            new_string_str = yuanshu[res.end():]
            chuli = yuanshu[:res.end()]
            chuli = chuli[:res.start()]

            chuli_jieshu = chuli_jieshu + chuli
        else:
            chuli = new_string_str[:res.end()]
            chuli_jieshu = chuli_jieshu + chuli
            new_string_str = new_string_str[res.end():]
    chuli_jieshu = chuli_jieshu + new_string_str
    chuli_jieshu = chuli_jieshu[1:-1]
    return chuli_jieshu


if __name__ == '__main__':
    asd = r"<strong>Description</strong><br />\r\n<br />\r\nThis item is well made of premium material for durable and practical use. With U-shaped design and heavy duty, it is with corrosion resistance in the saltwater environmentit and can be used to plug small yachts and boats. Besides, it can also be used as bags and home accessories.<br />\r\n<br />\r\n<strong>Feature</strong><br />\r\n<br />\r\n- Color: Silver.<br />\r\n- Material: Stainless steel.<br />\r\n- Size: Approx. 4.5 x 1.5 x 2 cm / 1.8 x 0.6 x 0.8 inch (L x W x H).<br />\r\n- Maximum load: 40kg.<br />\r\n- Corrosion resistance in the saltwater environment, high strength, durable and easy to install<br />\r\n- Welding firm, and carrying capacity.<br />\r\n- Bright surface polishing, beautiful appearance.<br />\r\n- Can be used to plug small yachts and boats, also be used as bags and home accessories.<br />\r\n- Install it on the ceiling in an area you would like to a light fixture, chandelier or ceiling fan.<strong>Description</strong><br />\r\n<br />\r\nThis item is well made of premium material for durable and practical use. With U-shaped design and heavy duty, it is with corrosion resistance in the saltwater environmentit and can be used to plug small yachts and boats. Besides, it can also be used as bags and home accessories.<br />\r\n<br />\r\n<strong>Feature</strong><br />\r\n<br />\r\n- Color: Silver.<br />\r\n- Material: Stainless steel.<br />\r\n- Size: Approx. 4.5 x 1.5 x 2 cm / 1.8 x 0.6 x 0.8 inch (L x W x H).<br />\r\n- Maximum load: 40kg.<br />\r\n- Corrosion resistance in the saltwater environment, high strength, durable and easy to install<br />\r\n- Welding firm, and carrying capacity.<br />\r\n- Bright surface polishing, beautiful appearance.<br />\r\n- Can be used to plug small yachts and boats, also be used as bags and home accessories.<br />\r\n- Install it on the ceiling in an area you would like to a light fixture, chandelier or ceiling fan.<strong>Description</strong><br />\r\n<br />\r\nThis item is well made of premium material for durable and practical use. With U-shaped design and heavy duty, it is with corrosion resistance in the saltwater environmentit and can be used to plug small yachts and boats. Besides, it can also be used as bags and home accessories.<br />\r\n<br />\r\n<strong>Feature</strong><br />\r\n<br />\r\n- Color: Silver.<br />\r\n- Material: Stainless steel.<br />\r\n- Size: Approx. 4.5 x 1.5 x 2 cm / 1.8 x 0.6 x 0.8 inch (L x W x H).<br />\r\n- Maximum load: 40kg.<br />\r\n- Corrosion resistance in the saltwater environment, high strength, durable and easy to install<br />\r\n- Welding firm, and carrying capacity.<br />\r\n- Bright surface polishing, beautiful appearance.<br />\r\n- Can be used to plug small yachts and boats, also be used as bags and home accessories.<br />\r\n- Install it on the ceiling in an area you would like to a light fixture, chandelier or ceiling fan."
    print(delete_word(asd,"ceiling"))
